# -*- coding: utf-8 -*-

from captcha.client import displayhtml
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.views.decorators.csrf import ensure_csrf_cookie
import settings

@ensure_csrf_cookie
def index(request):
    return render_to_response('template_Home.html',
                              needAuthForm(),
                              context_instance=RequestContext(request)
                              )
    
def needAuthForm(parm=None):
    public_key = settings.RECAPTCHA_PUBLIC_KEY
    recaptcha_script = displayhtml(public_key=public_key, attrs={'theme' : 'clean'})
    if parm is None :
        parm = {
                    'need_auth_form':True,
                    'recaptcha_widget':recaptcha_script,
                    } 
    else:
        parm.update({
                          'need_auth_form':True,
                          'recaptcha_widget':recaptcha_script,
                          })
    return parm